use super::*;
use std::io;

pub struct MoveCmd<'a> {
  source_path: &'a str,
  cos_path: &'a str,
}

impl<'a> MoveCmd<'a> {
  pub fn new(source_path: &'a str, cos_path: &'a str) -> Self {
    MoveCmd {
      source_path,
      cos_path,
    }
  }
}

impl<'a> BinaryCommand for MoveCmd<'a> {
  type Output = io::Result<bool>;
  fn exec(&self) -> Self::Output {
    if cfg!(target_os = "windows") {
      panic!("no impl for windows!")
    } else {
      Command::new(COS_BIN)
        .arg("move")
        .arg(self.source_path)
        .arg(self.cos_path)
        .spawn()?
        .wait()?;
      Ok(true)
    }
  }
}
